/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import model.dao.util.MySqlDataAccessHelper;
import model.pojo.FilterCpu;

/**
 *
 * @author TiOc
 */
public class FilterCpuDAO 
{
    public static ArrayList<FilterCpu> getFilterCpu()
    {
        ArrayList<FilterCpu> ds = new ArrayList<FilterCpu>();
        String sql = "SELECT * FROM FilterCpu As fc WHERE fc.isPublish = '1' ORDER BY fc.sizeCpu";
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();
        ResultSet rs = helper.executeQuery(sql); 
        try
        {
            while(rs.next())
            {
                FilterCpu fc = new FilterCpu();
                fc.setIdFilterCpu(rs.getInt("idFilterCpu"));
                fc.setSizeCpu(rs.getDouble("sizeCpu"));
                fc.setIsPublish(rs.getInt("isPublish"));
                ds.add(fc);
            }
        }
        catch(SQLException ex)
        {
            System.out.println(ex.getMessage());
        }
        helper.close();
        
        return ds;
    }
}
